<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>微信会员管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		function setUpMember(){
			var memberIds=new Array();
			$("[type=checkbox]:checkbox").each(function(){
				if($(this).is(':checked')){
					memberIds.push($(this).val());
				}
			});
			
			if(!memberIds.length){
				alert('请选择用户');
				return;
			}
			
			
			
			
			var bankCardNumber=$('#bankCardNumber').val();
			if("${type}"=='6' && (bankCardNumber==null || bankCardNumber=='')){
				alert('请填写银行卡号');
				return;
			}
			var tiRealName=$('#tiRealName').val();
			if("${type}"=='6' && (tiRealName==null || tiRealName=='')){
				alert('请填写真实姓名');
				return;
			}
			var openingBank=$('#openingBank').val();
			if("${type}"=='6' && (tiRealName==null || tiRealName=='')){
				alert('请填写开户号');
				return;
			}
			if("${type}"=='7'){
				var money=$('#money').val();
				tiRealName=$('#realName').val();
				
				var reason=$('#reason').val();
				if(money==null || money==''){
					alert('请填写支出金额');
					return;
				}
			}
			 $.post("${ctx}/jiujiu/jiuManufactor/setUpMember",{type:"${type}",factorId:"${factorId}",storeId:"${storeId}",memberIds:JSON.stringify(memberIds),tiRealName:tiRealName,money:money,reason:reason,bankCardNumber:bankCardNumber,openingBank:openingBank}, function(data){
				var jsonObj =JSON.parse(data);
				alert(jsonObj.message);
                if(jsonObj.msg=='success'){
	                parent.$.jBox.close(true);
	                parent.$('#Btn').click();
	                
                }
            });
            
            
            
			
		}
		
		
	</script>
</head>
<body>

		<div id="stack2" class="modal hide fade" tabindex="-1" data-focus-on="input:first">
		  <div class="modal-header">
		    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
		    <h3>请填写真实姓名（与微信绑定的银行卡姓名一致）</h3>
		  </div>
		  <div class="modal-body">
					
					
					<label class="control-label">银行卡号:</label>
					<div class="controls">
						<input id="bankCardNumber"  value=""/>
					</div>
					
					<label class="control-label">姓名:</label>
					<div class="controls">
						<input id="tiRealName"  value=""/>
					</div>
					
					<label class="control-label">开户行:</label>
					<div class="controls">
						<input id="openingBank"  value=""/>
					</div>
					
					
		 		
		  </div>
		  <div class="modal-footer">
		    <button type="button" class="btn btn-primary" onclick="setUpMember()">Ok</button>
		  </div>
		</div>

		<div id="stack3" class="modal hide fade" tabindex="-1" data-focus-on="input:first">
		  <div class="modal-header">
		    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
		    <h3>请填写真实姓名（与微信绑定的银行卡姓名一致） <br/>和   支出金额</h3>
		  </div>
		  <div class="modal-body">
					<label class="control-label">姓名:</label>
					<div class="controls">
						<input id="realName"  value=""/>
					</div>
					<label class="control-label">支出金额:</label>
					<div class="controls">
						<input id="money" type="number" value=""/>&nbsp;<span>请填整数呦</span>
					</div>
					<label class="control-label">支出缘由:</label>
					<div class="controls">
						<textarea rows="3" cols="20" id="reason"></textarea>
					</div>
		 		
		  </div>
		  <div class="modal-footer">
		    <button type="button" class="btn btn-primary" onclick="setUpMember()">Ok</button>
		  </div>
		</div>



	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/wechat/wechatMember/">微信会员列表</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="wechatMember" action="${ctx}/jiujiu/jiuManufactor/memberList" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input id="type" name="type" type="hidden" value="${type}"/>
		<input id="factorId" name="factorId" type="hidden" value="${factorId}"/>
		<input id="storeId" name="storeId" type="hidden" value="${storeId}"/>
		<label>姓名 ：</label><form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
	</form:form>
	
	
<div style="overflow:scroll;">
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered ">
		<thead><tr>
		<th>选择</th>
		<th>头像</th>
		<th>昵称</th>
		<th>性别</th>
		<tbody>
		<c:forEach items="${page.list}" var="wechatMember">
			<tr>
				<td><input name="member" type="checkbox" value="${wechatMember.id}" /></td>
				<td><img src="${wechatMember.headimgurl}"   style="width:40px;height:40px"  /></td>
				<td>
					${empty wechatMember.name ?wechatMember.nickname:wechatMember.name}
				</td>
				<td>${wechatMember.sex}</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
</div>		
	<div class="pagination">${page}</div>
	<center>
		<c:choose>
		    <c:when test="${type eq 6}">
		       <button class="demo btn btn-primary btn-large" data-toggle="modal" href="#stack2">提交</button>
		    </c:when>
		    <c:when test="${type eq 7}">
		       <button class="demo btn btn-primary btn-large" data-toggle="modal" href="#stack3">提交</button>
		    </c:when>
		    <c:otherwise>
		<input style="width:350px" class="btn btn-primary" type="button" value="确认" onclick="setUpMember()"/>
		    </c:otherwise>
		</c:choose>
	</center>
	
	
</body>
</html>
